<template>
	<view class="uni_box home">
		<!-- <navbar title='债务委托' :yin="false">
		</navbar> -->
		<view class="fone">
			<image class="img_fx" src="/static/img/img_rgzx.png"></image>
			<view class="foneview">
				<u-icon name="arrow-left" color="#333" size="40" @click="getfan"></u-icon>
				<image class="fxtit" src="/static/img/rengong.png"></image>
				<text class="hmiao">律小狮——守护就在您身边</text>
			</view>
		</view>
		<view class="content">

			<view class="xinxi">
				<view class="weiqi" v-if="type=='edit'">
					<image class="zhaiicon" src="/static/img/zhaiicon.png" />
					<text class="weiri">委托日期:2024-3-1</text>
				</view>
				<view class="uone">
					<view class="ushuru">
						<text class="xing">*</text>
						<text class="lval">客户名称：</text>
						<u-input v-model="pinfo.name" type="text" :border="false" placeholder="请输入"/>
					</view>
				</view>
				<view class="uone">
					<view class="ushuru">
						<text class="xing">*</text>
						<text class="lval">联系方式：</text>
						<u-input v-model="pinfo.phone" type="text" :border="false" placeholder="请输入"/>
					</view>
				</view>
				<view class="uone" @click="dishow=true">
					<view class="ushuru">
						<text class="xing">*</text>
						<text class="lval">您的所在地：</text>
						<u-input v-model="pinfo.location" type="text" :border="false" placeholder="请输入"/>
						<!-- <view class="sexuan">
							<text class="xuanname">{{ diinfo?diinfo:'请选择起诉地' }}</text>
							<image class="ricons" src="/static/mine/ricons.png" />
						</view> -->
					</view>
				</view>
				<view class="uone">
					<view class="ushuru">
						<text class="lval">方便通话时间：</text>
						<view class="sexuan">
							<text class="xuanname" @click="getshijian(1)">{{ startime?startime:'开始时间' }}</text>
							<text style="display: inline-block;margin: 0 20rpx;">-</text>
							<text class="xuanname" @click="getshijian(2)">{{ endtime?endtime:'结束时间' }}</text>
							<!-- <image class="ricons" src="/static/mine/ricons.png" /> -->
						</view>
						<!-- <u-input v-model="pinfo.appoint_time" type="text" :border="false" placeholder="请输入"/> -->
					</view>
				</view>
			</view>
			</view>

			<view class="botview">
				<!-- <view class="botbtn" @click="getshenqing">申请委托</view> -->
				<view class="quxiaoviewthree">
					<view class="shifu">
						<view class="fuone">
							<text class="sname">剩余通话：</text>
							<text class="fujia">{{vinfo.surplus}}/{{ vinfo.total }}</text>
						</view>
						<text class="jiaru">加入会员免费下载</text>
					</view>
					<view class="rbtn">
						<view class="popquview" @click="gethuiyuan()" v-if="vinfo.is_vip==0">开通会员</view>
						<view class="popquview quebtn" @click="getshenqing()">确认提交</view>
					</view>
				</view>
			</view>


		<u-select v-model="bshow" :list="blist" @confirm="bconfirm"></u-select>

		<!-- 温馨提示 -->
		<view class="yhupopview">
			<u-popup v-model="wenshow" mode="center" @close="popclose(1)" width="82%" :closeable="true" z-index="1000">
				<view class="yhpop">

					<text class="yhtit">
						温馨提示
					</text>
					<image class="tishibg" src="/static/img/tishibg.png" />
					<text class="anshou">您的案件已提交受理!</text>
					<text class="anmiao">请您前往我的-我的委托获取服务</text>
					<view class="quxiaoview">
						<!-- <view class="popquview" @click="popclose(1)">取消</view> -->
						<view class="popquview quebtn" @click="popclose(1)">立即前往</view>
					</view>
				</view>
			</u-popup>
		</view>
		<!-- 温馨底层 -->
		<view class="yhupopview">
			<u-popup v-model="wxshow" mode="bottom" @close="popclose(2)" width="100%" :closeable="true" z-index="1000">
				<view class="yhpop">

					<text class="yhtit">
						温馨提示
					</text>
					<image class="wenxin" src="/static/img/wenxin.png" />
					<view class="wenmiao">
						请您再次确认，您提交的信息资料真实合法有效完整，不存在任何虚假陈述、伪造、变造等违反法律规定的情形，您理解且清楚明白您提供的信息资料若存在缺漏违规、虚假陈述、伪造、变造等违反法律规定可能导致的法律后果及法律责任，您应对您的信息资料完整性、虚假陈述、伪造、变造等违反法律规定提供的信息资料自行承担一切责任；本平台给予您的回复内容及文书内容均系基于您提供的相关信息及材料为基础，不为此承担任何责任，望悉知！
					</view>
					<view class="quxiaoviewtwo">
						<view class="popquview" @click="popclose(2)">取消</view>
						<view class="popquview quebtn" @click="popclose(2)">确认委托</view>
					</view>
				</view>
			</u-popup>
		</view>

		<!-- <Adresspop :dishow="dishow" @adressclose="dishow=false" @adressbtn="adressbtn"></Adresspop> -->
		<u-calendar v-model="timeshow" :mode="mode" max-date="2150-01-01" @change="timechange"></u-calendar>

		<u-picker mode="time" v-model="sjianshow" :params="params"  @confirm="sjianconfirm"></u-picker>
	</view>
</template>

<script>
// import Adresspop from "@/components/Adresspop/Adresspop";
import {
		baseUrl
	} from '@/utils/config.js';
	export default {
		components:{
			// Adresspop
		},
		data() {
			return {
				value:'',
				wang:'',
				bshow:false,
				mode:'date',
				timeshow:false,
				timetype:1,//1纠纷时间 2约定还款时间
				blist:[
					{
						value: '1',
						label: '江'
					},
					{
						value: '2',
						label: '湖'
					}
				],
				mineinfo:{
					profile:{
						avatar:'',
						email:''
					}
				},
				passwd:'',
				passwd_confirmation:'',
				code:'',

				timer: null,
				time: 60,
				isTimer: false,
				headimg:'',
				head_portrait:'',//传给接口

				wenshow:false,
				wxshow:false,
				psdshow:false,
				pinfo:{
					name:'',//姓名
					phone:'',//手机号
					location:'',//所在地
					convenient:'',//方便通话时间
				},
				dishow:false,
				diinfo:"",
				newdiinfo:{},
				type:'add',//add 新增 edit编辑

				params: {
					year: false,
					month: false,
					day: false,
					hour: true,
					minute: true,
					second: false
				},
				sjianshow: false,
				startime:'',
				endtime:'',
				sjiantype:1,//1开始 2结束
				vinfo:{}
			}
		},
		onLoad() {
			this.getartificial()
		},
		onShow() {
		},
		methods: {
			async getartificial(){
				let res = await this.$u.api.artificial({
				});
				this.vinfo = res
			},
			upload(e) {
				// this.updatetype = e
				uni.chooseImage({
					count: 1,
					success: (chooseImageRes) => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
						this.headimg = tempFilePaths[0];
						// this.isClick = true;
						this.unloadtou()
						// this.getavatar();//修改信息
					}
				});
			},
			unloadtou(){
				// console.log(this.head_portrait)
				let that = this
				uni.uploadFile({
					// url: baseUrl + '/api/uploadImage', //仅为示例，非真实的接口地址
					url: baseUrl + '/api/edit_user', //仅为示例，非真实的接口地址
					filePath: this.headimg,
					name: 'avatar',
					header: {
						// 'content-type': 'application/json;charset=UTF-8',
						'Authorization': 'Bearer '+uni.getStorageSync('token'),
					},
					formData: {
						'Authorization':'Bearer '+uni.getStorageSync('token'),
					},
					success: (uploadFileRes) => {
						console.log( JSON.parse(uploadFileRes.data).data);
						if(JSON.parse(uploadFileRes.data).success == 200){
							that.head_portrait = JSON.parse(uploadFileRes.data).data
							// that.getavatar();//修改信息
							that.getuserinfo();//刷新接口
							// that.user.head_portrait = JSON.parse(uploadFileRes.data).data.src
						}else{
							that.$u.toast(JSON.parse(uploadFileRes.data).message);
						}
						// that.getinfo()
					}
				});
			},
			async getavatar(){
				let res = await this.$u.api.edit_user({
					avatar:this.headimg
				});
				this.$u.toast("上传成功");
			},
			async getuserinfo(){
				let res = await this.$u.api.userinfo({
				});
				this.mineinfo = res
			},
			async getpsdedit(){
				if(!this.passwd){
					this.$u.toast("请输入密码");
					return false;
				}
				if(!this.passwd_confirmation){
					this.$u.toast("请输入确认密码");
					return false;
				}
				if(!this.code){
					this.$u.toast("请输入邮箱验证码");
					return false;
				}
				if(this.passwd.length<8){
					this.$u.toast('密码最小长度为8位');
					return false
				}
				if(this.passwd != this.passwd_confirmation){
					this.$u.toast('确认两次密码是否一致');
					return false
				}
				if(this.startime==''&&this.endtime==''){
					this.pinfo.convenient =''
				}else{
					this.pinfo.convenient = this.startime+'-'+this.endtime
				}
				
				let res = await this.$u.api.editPasswd({
					passwd:this.passwd,
					passwd_confirmation:this.passwd_confirmation,
					code:this.code,
					// type:'RESET_PASS'
				});
				this.$u.toast("操作成功");
				console.log(res)
			},
			xuanwang(){
				this.bshow = true
			},
			bconfirm(e){
				console.log(e)
				this.wang = e[0].value
			},
			getrightClick(){
				this.navrouter("/pages/TPage/BiRecord?type=2");
			},
			async getcode(){
				if(!this.mineinfo.profile.email){
					this.$u.toast("请输入邮箱");
					return false;
				}
				this.isTimer = true;
				this.timer = setInterval(() => {
					this.time--
					if (this.time < 0) {
						this.isTimer = false;
						this.time = 60;
						clearInterval(this.timer);
					};
				}, 1000);
				let res = await this.$u.api.sendEmail({
					email: this.mineinfo.profile.email,
					type:'RESET_PASS'
				});
				// console.log(res)
				this.$u.toast("发送成功");
			},
			popclose(e){
				if(e == 1){
					this.wenshow = false
				}else if(e == 2){
					this.wxshow = false
				}else if(e == 3){
					this.psdshow = false
				}
			},
			ziliaoClick(e){
				if(e == 1){
					//发票管理
					this.navrouter("/pages/TPage/FaPiaoManage");
				}else if(e == 2){
					//联系我们
					this.navrouter("/pages/TPage/LianXi");
				}else if(e == 3){
					//隐私协议
					this.navrouter("/pages/TPage/Xieyi");
				}
			},
			getDetail(){
				this.navrouter("/pages/TPage/ZhaiWeiDetail");
			},
			async adressbtn(e){
				console.log(e)
				this.newdiinfo = e
				this.diinfo = this.newdiinfo.province+'-'+this.newdiinfo.city+'-'+this.newdiinfo.area
				this.pinfo.province_id = this.newdiinfo.provinceid
				this.pinfo.city_id = this.newdiinfo.cityid
				this.pinfo.area_id = this.newdiinfo.areaid
			},
			gettime(e){
				this.timetype = e
				this.timeshow = true

			},
			timechange(e){
				// console.log(e)
				if(this.timetype == 1){
					this.pinfo.dispute_time = e.result
				}else if(this.timetype == 2){
					this.pinfo.appoint_time = e.result
				}
			},
			async getshenqing(){
				if(!this.pinfo.name){
					this.$u.toast("请输入客户名称");
					return false;
				}
				if(!this.pinfo.phone){
					this.$u.toast("请输入联系方式");
					return false;
				}
				if(!this.pinfo.location){
					this.$u.toast("请选择您的所在地");
					return false;
				}
				if(this.startime==''&&this.endtime==''){
					this.pinfo.convenient =''
				}else{
					this.pinfo.convenient = this.startime+'-'+this.endtime
				}
				let res = await this.$u.api.artificialpost(this.pinfo);
				this.$u.toast("操作成功");
				setTimeout(() => {
					uni.navigateBack()
				}, 1500);
			},
			getfan(){
				uni.navigateBack()
			},
			getshijian(e){
				this.sjiantype = e
				this.sjianshow = true
			},
			sjianconfirm(e){
				console.log(e)
				if(this.sjiantype == 1){
					this.startime = e.hour+':'+e.minute
				}else if(this.sjiantype == 2){
					this.endtime = e.hour+':'+e.minute
				}
			},
			gethuiyuan(){
				this.navrouter("/pages/TPage/VIpServices");
			}

		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #fff;
	}
	.chongji{
		width: 38rpx;
		height: 36rpx;
	}

	.content{
		background-color: #fff;
		padding: 30rpx 30rpx 150rpx;
		min-height: 100vh;
		margin-top: -50rpx;
		position: relative;
		border-radius: 25rpx 25rpx 0 0;
		.xinxi{
			background: #FFFFFF;
			border-radius: 30rpx;
			// padding: 0 30rpx;
		}
		.mpone{
			display: flex;
			flex-direction: row;
			align-items: center;
			padding: 30rpx 0;
			border-bottom: 1rpx solid #EEEEEE;

			.touview{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				margin-right: 30rpx;
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.tou2{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				position: absolute;
			}
			.xj{
				position: relative;
				z-index: 1;
				width: 42rpx;
				height: 38rpx;
			}
			.mpright{
				flex: 1;
				display: flex;
				flex-direction: column;
				padding-left: 50rpx;
				.xiugai{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 30rpx;
					color: #666666;
				}
				.yxname{
					font-family: Source Han Sans CN;
					font-weight: bold;
					font-size: 24rpx;
					color: #000000;
				}
				.dengview{
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-top: 10rpx;
					.idnum{
						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 24rpx;
						color: #000000;
						display: inline-block;
						margin-right: 13rpx;
					}
					.dengji{
						padding: 5rpx 30rpx;
						background: #FF8004;
						border-radius: 14rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 20rpx;
						color: #FFFFFF;
					}
				}
			}
		}
		.qian{
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 45rpx;
			.qbiao{
				display: inline-block;
				width: 8rpx;
				height: 36rpx;
				background: #FF8004;
				margin-right: 8rpx;

			}
			.qname{
				font-family: Source Han Sans CN;
				font-weight: bold;
				font-size: 30rpx;
				color: #000000;
			}
		}
		.weiqi{
			padding: 30rpx;
			border-bottom: 10rpx solid #EEEEEE;
			display: flex;
			flex-direction: row;
			align-items: center;
			.zhaiicon{
				width: 40rpx;
				height: 40rpx;
				margin-right: 4rpx;
			}
			.weiri{
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #111111;
			}
		}
		.xing{
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #F42020;
		}
		.uone{
			display: flex;
			flex-direction: column;
			// margin-bottom: 40rpx;
			background: #F8F8F8;
			border-radius: 16rpx;
			padding: 0 30rpx;
			margin-bottom: 20rpx;
			.uhead{
				display: flex;
				flex-direction: row;
				align-items: center;

			}
			.usdt{
				width: 46rpx;
				height: 46rpx;
				margin-right: 12rpx;
			}
			.uname{
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 24rpx;
				color: #000000;
			}
		}
		.ushuru{
			padding: 35rpx 0rpx;
			display: flex;
			align-items: center;
			flex-direction: row;
			border-bottom: 1rpx solid #eee;
			.lval{
				font-weight: 500;
				font-size: 28rpx;
				color: #111111;
				display: inline-block;
				margin-right: 20rpx;
			}
			.ricons{
				margin-left: 30rpx;
				width: 30rpx;
				height: 30rpx;
			}
			.ml{
				margin-left: auto;
			}
			/deep/.u-input__input{
				font-weight: 400;
				font-size: 28rpx;
				color: #000000;
				min-height: 20px !important;
			}
			.xingview{
				margin-left: auto;
				display: flex;
				flex-direction: row;
				align-items: center;
				.xitem{
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-left: 70rpx;
					.sexs{
						width: 30rpx;
						height: 30rpx;
						margin-right: 8rpx;
					}
					text{
						font-family: PingFang SC;
						font-weight: 400;
						font-size: 30rpx;
						color: #111111;
					}
				}
			}
			.xuantit{
				color: #c0c4cc;
			}
			.xactive{
				font-weight: 400;
				font-size: 28rpx;
				color: #000000;
			}
			.xia{
				margin-left: auto;
				width: 16rpx;
				height: 10rpx;
			}
			.quanbu{
				margin-left: 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 28rpx;
				color: #010101;
			}
			.huoqu{
				padding: 8rpx 28rpx;
				margin-left: 30rpx;
				background: rgba(255, 128, 4, 1);
				border-radius: 50rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 28rpx;
				color: #FFFFFF;
			}
		}
		.keyong{
			display: block;
			text-align: right;
			font-family: Source Han Sans CN;
			font-weight: 400;
			font-size: 22rpx;
			color: #010101;
			margin-bottom: 75rpx;
		}
		
		.sbotview{
			margin: 100rpx 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			.shoufei{
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 22rpx;
				color: #010101;
				display: block;
				margin-bottom: 15rpx;


			}
			.btn{
				width: 100%;
				height: 80rpx;
				background: #030000;
				border-radius: 40rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: Source Han Sans CN;
				font-weight: 500;
				font-size: 30rpx;
				color: #FFFFFF;
			}
		}
		.sexuan{
			margin-left: auto;
			display: flex;
			align-items: center;
			.xuanname{
				font-family: PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #999999;

			}
			.ricons{
				width: 30rpx;
				height: 30rpx;
				margin-left: 12rpx;

			}
		}
		.rbiaos{
			font-weight: 400;
			font-size: 28rpx;
			color: #999999;
			display: inline-block;
			margin-left: 15rpx;
		}
		// padding-bottom: 150rpx;
	}

	.yhupopview{
		/deep/.u-mode-center-box{
			background-color: transparent;
		}
		.yhpop{
			border-radius: 24rpx;
			padding: 40rpx;
			background-color: #fff;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			.yhtit{
				display: block;
				text-align: center;
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #333333;
				margin-bottom: 45rpx;
			}
			.wenxin{
				width: 100%;
				height: 280rpx;

			}
			.wenmiao{
				display: block;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
				margin: 30rpx 0;
			}
			.tishibg{
				width: 300rpx;
				height: 240rpx;
			}
			.anshou{
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: #333333;
				display: block;
				margin: 20rpx 0;
			}
			.pinput{
				background: #F5F5F5;
				border-radius: 10rpx;
				padding:10rpx 20rpx;
				margin-bottom: 20rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
			}
			.huoqu{
				margin-left: 20rpx;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #496EE7;
			}
			.quxiaoviewtwo{
				display: flex;
				flex-direction: row;
				margin-top: 40rpx;
				justify-content: center;
				width: 100%;
				.popquview{
					height: 90rpx;
					border-radius: 10rpx;
					border: 1rpx solid #111111;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 90%;
				}
				.quebtn{
					background: #3E65E5;
					color: #fff;
					border: 1rpx solid #3E65E5;
				}
			}
			.quxiaoviewtwo{
				display: flex;
				flex-direction: row;
				margin-top: 40rpx;
				justify-content: space-between;
				width: 100%;
				.popquview{
					height: 90rpx;
					border-radius: 10rpx;
					border: 1rpx solid #111111;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 48%;
				}
				.quebtn{
					background: #3E65E5;
					color: #fff;
					border: 1rpx solid #3E65E5;
				}
			}
		}
	}
	.antwo{
		background: #FFFFFF;
		border-radius: 20rpx;
		// margin: 30rpx 30rpx 0;
		padding: 30rpx;
		display: flex;
		flex-direction: column;
		.anlist{
			display: flex;
			flex-direction: row;
			align-items: center;
			// padding: 20rpx 0;
			border-bottom: 1rpx solid #EEEEEE;
			.antit{
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #111111;
			}
		}
		.neiview{
			flex-direction: column;
			align-items: flex-start;
			border-bottom: none;
			
		}
		.wenben{
			height: 200rpx;
			background: #F5F5F5;
			border-radius: 20rpx;
			padding: 20rpx;
			width: 100%;
			margin-top: 30rpx;
		}

	}
	.botview{
			position: fixed;
			width: 100%;
			height: 120rpx;
			background-color: #fff;
			bottom: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			.botbtn{
				height: 88rpx;
				background: #3E65E5;
				border-radius: 20rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
				width: 94%;
			}
		}
		.fone{
			position: relative;
			height: 500rpx;
			.img_fx{
				position: absolute;
				width: 100%;
				height: 100%;
			}
			.foneview{
				position: relative;
				padding: 30rpx;
				display: flex;
				flex-direction: column;
			}
			.fxtit{
				width: 280rpx;
				height: 64rpx;
				margin: 56rpx 0 20rpx;
			}
			.hmiao{
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 24rpx;
				color: #3570D8;
			}
		}

		.quxiaoviewthree{
				display: flex;
				flex-direction: row;
				// margin-top: 40rpx;
				padding: 0 20rpx;
				width: 100%;
				.shifu{
					display: flex;
					flex-direction: column;
					.fuone{
						display: flex;
						flex-direction: row;
						align-items: center;
						.sname{
							font-family: PingFang SC;
							font-weight: 500;
							font-size: 25rpx;
							color: #999999;
						}
						.fujia{
							font-weight: bold;
							font-size: 28rpx;
							color: #3E65E5;
							position: relative;
							top: -4rpx;
						}
						.funum{
							font-size: 40rpx;
						}
					}
					.jiaru{
						font-family: PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #999999;
					}
				}
				.rbtn{
					width: 60%;
					display: flex;
					flex-direction: row;
					justify-content: flex-end;
					margin-left: auto;

				}

				.popquview{
					height: 80rpx;
					border-radius: 10rpx;
					background: linear-gradient(90deg, #F4DAB5, #E7B775);
					border-radius: 10rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 40%;
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 26rpx;
					color: #52360F;
				}
				.quebtn{
					background: #3E65E5;
					color: #fff;
					border: 1rpx solid #3E65E5;
					margin-left: 20rpx;
				}
			}
</style>
